#include "orbitersdk.h"
#include "UMmuSDK.h"
#include "UCGOCargoSDK.h"

// Sound  slots variables
#define AlarmSnd	0
#define FuelDump	1
#define WakeUp		2

//Vessel helper structures
//struct animcompinfo
//{
//	int msh,id,tp,grp,parent;
//	VECTOR3 ref,axshsc;
//	float angle;
//	double st0,st1;
//	MGROUP_TRANSFORM *cmpdef;
//	ANIMATIONCOMPONENT_HANDLE cmpt;
//};
//struct animinfo
//{
//	UINT id;
//	DWORD tp,repeat;
//	DWORD trigkey;
//	int status;
//	double spd,proc,init;
//	int grpcnt;
//	int compcnt;
//	unsigned int **grp;
//	animcompinfo *comp;
//};

//Vessel constants
#define ANIM_COUNT 5

//Vessel class
class ShuttlePBMk2:public VESSEL3 {
public:
	ShuttlePBMk2(OBJHANDLE hObj,int fmodel);
	~ShuttlePBMk2();
	
	PSTREAM_HANDLE pSmoke;
	PSTREAM_HANDLE pAoA[2];
	PSTREAM_HANDLE pMach;

	double stress;
	double lvl;
	double MaxQ;
	int iRandomID;

	// UMMU 2.0 DECLARATION
	void InitUMmu();
	UMMUCREWMANAGMENT Crew;
	int iSelectedUmmuMember;	// for the SDK demo, select the member to eva
	// The HUD display method variable
	char cUmmuHudDisplay[255];	// UMmu hud char variable
	double dHudMessageDelay;	// UMmu hud display delay
	char *SendHudMessage(void);	// UMmu hud display function
	// Add UMmu to Vessel see doc
	char cAddUMmuToVessel[255];
	void AddUMmuToVessel(BOOL bStartAdding=FALSE);
	 //UMmu Realism part
	double dOldVertSpeed;		// UMmu vertical speed to kill crew
	int iAliveUMMU;				// UMmu number of crew with pulse > 0

	void clbkSetClassCaps(FILEHANDLE cfg);
	void clbkVisualCreated(VISHANDLE vis, int refcount);
	//void clbkPostCreation(void);
	void clbkLoadStateEx(FILEHANDLE scn,void *vs);
	void clbkSaveState(FILEHANDLE scn);
	void clbkPreStep(double simt, double simdt, double mjd);
	void clbkPostStep(double simt,double simdt,double mjd);
	int  clbkConsumeBufferedKey(DWORD key,bool down,char *kstate);
	bool clbkDrawHUD(int mode, const HUDPAINTSPEC *hpc, oapi::Sketchpad *skp);

	void DefineThrusters();
	void ClearThrusters();
	int KillUMmu();

	PROPELLANT_HANDLE ph_h[2];
	THRUSTER_HANDLE th_h[17];
	double thMainLevel;
	double thHoverLevel;
	THGROUP_HANDLE thg_h[15];

	double altitude;
	double mnb;
	double aoa;

	// UCGO variables part
	void InitUCGO();
	UCGO hUcgo;
	int iSelectedCargo;

	// Other funcs
	double DEGto01(const double angle);
	PARTICLESTREAMSPEC DeclareParticleStream(DWORD flag, double srcsize, double srcrate, double v0, double srcspread, double lifetime, double growthrate, double atmslowdown, enum PARTICLESTREAMSPEC::LTYPE ltype, enum PARTICLESTREAMSPEC::LEVELMAP levelmap, double lmin, double lmax, enum PARTICLESTREAMSPEC::ATMSMAP atmsmap, double amin, double amax, SURFHANDLE tex);

	// Textures handle
	SURFHANDLE mainex;
	SURFHANDLE mainsmoke;
	SURFHANDLE hoversmoke;
	SURFHANDLE ventilesmoke;
	SURFHANDLE machsmoke;

	// Destruct vars
	BOOL MainRepair0;
	BOOL MainRepair1;
	BOOL MainRepair2;

	// Fuel dump
	double dDumpRate;

	// Debug
	bool bShowDebug;
};
